<?php

	include ("config/env.php");
	include 'lib/actions.php';
switch(MODE) {
  case 'dev':
  case 'test':
      // Affichage de toutes les erreurs sauf notice
      error_reporting(E_ALL^E_NOTICE);
      ini_set('display_errors',1);
      break;
    default:
    // Pas d'affichage des erreurs, mais consignation de toutes les erreurs sauf notice
    error_reporting(E_ALL^E_NOTICE);
    ini_set('display_errors',0);
  }
///////////// Redirection

if($_GET['microurl']){

    include('actions/redirect.php');
	exit;
}

///////////// Actions

$filename = preg_replace("#\W+#", "" ,$_GET['action']);	
$filename = $filename ? $filename : "form";
if (file_exists("actions/".$filename.".php"))
{
	include("actions/".$filename.".php");
	
	// =======================
	// = Démarrage de la vue =
	// =======================
	
	include 'lib/view.php';

	ob_start();
	include("view/tpl_".$filename.".php");
	$content = ob_get_contents();
	ob_clean();
	if(isAjax()) {
  	include("view/tpl_global.ajax.php"); 
	} else {
	  include("view/tpl_global.php");
  }
}


?>